package cn.lightpm.entity.meeting;

import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import cn.lightpm.entity.AbstractEntity;
import cn.lightpm.entity.account.User;

import com.google.common.collect.Lists;

@Entity
@Table(name = "MEETING")
public class Meeting extends AbstractEntity {

	private static final long serialVersionUID = 3504374890561221414L;

	private String title;

	private Date date;

	private String place;

	/**
	 * 持续时间，单位：分钟
	 */
	private Integer duration;

	private List<User> participantList = Lists.newArrayList();

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public String getPlace() {
		return place;
	}

	public void setPlace(String place) {
		this.place = place;
	}

	public Integer getDuration() {
		return duration;
	}

	public void setDuration(Integer duration) {
		this.duration = duration;
	}

	@ManyToMany
	@JoinTable(name = "MEETING_MEMBER", joinColumns = { @JoinColumn(name = "MEETING_ID") }, inverseJoinColumns = { @JoinColumn(name = "USER_ID") })
	@Fetch(FetchMode.SUBSELECT)
	@OrderBy("id")
	public List<User> getParticipantList() {
		return participantList;
	}

	public void setParticipantList(List<User> participantList) {
		this.participantList = participantList;
	}

}
